package com.cino.demos;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class EntrySet {

    public static void main(String[] args) {
        //创建一个HashMap
        HashMap<String, Integer> map = new HashMap<>();

        //添加一些健值对
        map.put("a",10);
        map.put("b",20);
        map.put("c",30);

        //使用entrySet()遍历Map
        Set<Map.Entry<String, Integer>> entrySet = map.entrySet();
        for (Map.Entry<String, Integer> entry : entrySet) {
            String key = entry.getKey();    //获取key
            Integer value = entry.getValue();   //获取value
            System.out.println("key: "+key+",value: "+value);
        }
    }
}
